libname ETHAN '/fin/hmda1/m1kpb00/CohenCole/Unzipped/';
libname EWORK '/fin/hmda1/m1kpb00/CohenCole/Work/';


data junk03; set ETHAN.credit103; run;
proc sort data=junk03; by person; run;

data junk04;  set ETHAN.credit104; run;
proc sort data=junk04; by person; run;

data add03; set ETHAN.credit103_2; run;
proc sort data=add03; by person; run;

data add04; set ETHAN.credit104_2; run;
proc sort data=add04; by person; run;

data both03; merge junk03 add03; by person; year = 2003; run;
data both04; merge junk04 add04; by person; year = 2004; run;

data EWORK.both;
  set both03 both04;

  lat=(substr(llongv,1,7)*1)/10000;   * Convert to numeric
  long=-(substr(llongv,9,7)*1)/10000; * Convert to numeric
  
  availcrd = re28 - re33; 
run;


data fordistance;
  set EWORK.both (keep = lat long);
  where (lat>0 & long<0);
run;

proc sort data=fordistance noduprec;
  by lat long;
run;

proc export data=fordistance outfile="/fin/hmda1/m1kpb00/CohenCole/Work/fordistance.csv" dbms=CSV replace;
run;

proc print data=EWORK.both (obs=25);
  var person state county tract block lat long llongv llongl;
run;
